package com.romotc.qqrobot.webqq.qqInterfaceCall.dataProcessor;

import java.util.Iterator;

import org.json.JSONObject;

import com.romotc.common.http.CookieUtil;
import com.romotc.qqrobot.bean.QQLogedin;
import com.romotc.scache.RequestSpy;
/**
 * 处理请求返回的Cookie信息
 * @author romotc
 *
 */
public class SessioinProcessor implements DateProcessor {


	@Override
	public JSONObject processResponse(QQLogedin loginQQ, RequestSpy rqSpy,
			JSONObject reqDataObj) throws Exception {
		//原Cookie
		String cookieStr = loginQQ.getCookieString();
		JSONObject cookieObj = CookieUtil.parseCookieJsonFromStr(cookieStr);
		
		//新返回的Cookie
		JSONObject resCookies = rqSpy.getResCookiesJson(cookieObj);
		loginQQ.setCookieString(CookieUtil.parseCookieJsonToStr(resCookies));
		
		return reqDataObj;
	}

	private static DateProcessor instance;
	public synchronized static DateProcessor getInstance() {
		if(instance == null) 
			instance = new SessioinProcessor();
		return instance;
	}
}
